package com.zyk.leetcode;

import java.util.HashSet;
import java.util.Set;

/**
 *
 * https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/
 *
 * @author zhangsan
 * @date 2021/4/3 19:48
 */
public class J03 {

    public static int findRepeatNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            if(set.contains(num)) {
                return num;
            }
            set.add(num);
        }
        return -1;
    }


    // for test
    public static void main(String[] args) {

    }

}
